<?php
class forum_replyMod extends commonMod
{
    public function __construct()
    {
        parent::__construct();
    }

    public function index(){
        //分页信息
        $listRows=5;
        $url = __URL__ . '/index/page-{page}.html'; //分页基准网址
        $limit=$this->pagelimit($url,$listRows);
     //内容列表          //查询数据库表forum_reply_bbs所有字段
        $list=$this->model->table("forum_reply_bbs")->order(" id desc ")->limit($limit)->select();
       //forum_cards_bbs“帖子ID”关联forum_cards_bbs
        if ($list){
        	foreach ($list as $k=>$v){
        		$forum=$this->model->table('forum_cards_bbs')->where(" id = '".$v['cards_id']."' ")->find();
        		//dump($forum);
        		$list[$k]['forum_title'] = $forum['forum_title'];
        		unset($forum);
        	}
        }
        
        $this->list = $list;
        $count=$this->model->table("forum_reply_bbs")->count();
        $this->page=$this->page($url, $count, $listRows);       
        $this->show();
    }

    public function add(){
    	$this->show();
    }

    public function act_add(){
    	$data = $_POST;
    	$data['reply_time'] = time();
    	$this->model->table("forum_reply_bbs")->data($data)->insert();
        $this->msg('添加成功！',1);
    }

    public function edit(){
    	$id = $_GET['id'];
    	$this->info = $this->model->table("forum_reply_bbs")->where(" id = '".$id."' ")->find();
    	$this->show();
    }

   public function act_edit(){
      $data = $_POST;
      $data['reply_time'] = time();
  //    $data['last_time'] = time();
      $this->model->table("forum_reply_bbs")->where(" id = '".$_POST['id']."' ")->data($data)->update();
      $this->msg('添加成功！',1);
    }

    public function del(){
    	$id=intval($_POST['id']);
        $this->alert_str($id,'int',true);        
        $status=$this->model->table("forum_reply_bbs")->where(" id = '".$id."' ")->delete();       
        $this->msg('删除成功！',1);
    }
   
}
?>